/**
 * @name 08_getNamespace
 */

import java

predicate isOgnlSink(Expr arg) {
  exists (Method m, MethodAccess ma
  | m.getName() = "compileAndExecute" and
    ma.getMethod() = m and
    arg = ma.getArgument(0))
}

/* Refactor the logic into a predicate. */
predicate isActionProxySource(MethodAccess ma) {
  exists (Method m, Method n
  | m.getName() = "getNamespace" and
    m.getDeclaringType().getName() = "ActionProxy" and
    n.overrides*(m) and
    ma.getMethod() = n)
}

/* This query produces identical results to the previous one. We have just
 * refactored the logic into a separate predicate.
 */
from MethodAccess ma
where isActionProxySource(ma)
select ma
